package com.java.controller;

import com.java.Entry;
import com.java.service.LoginService;
import com.java.vo.Result;

/**
 * 用户登录、注销操作
 */
public class LoginController {
	
	private LoginService loginService;
	
	public LoginController() {
		this.loginService = new LoginService();
	}

	/**
	 * 登录操作
	 */
	public void login() {
		System.out.println("登录：");
		while (true) {
			System.out.println("请输入用户名：");
			String username = Entry.scanner.nextLine();
			System.out.println("请输入密码：");
			String password = Entry.scanner.nextLine();
			
			Result result = loginService.login(username, password);
			System.out.println(result.getMsg());
			if (result.isStatus()) {
				break;
			}
		}
	}
	
	/**
	 * 注销登录
	 */
	public void logout() {
		loginService.logout();
	}
	
}
